{extend name='common/content' /}

{block name="button"}
<div class="nowrap pull-right" style="margin-top:10px">
    {if auth("$classuri/add")}
    <button data-modal='{:url("$classuri/add")}' data-title="添加{$title}" class='layui-btn layui-btn-small'><i
            class='fa fa-plus'></i> 添加{$title}
    </button>
    {/if}
    {if auth("$classuri/del")}
    <button data-update data-field='delete' data-action='{:url("$classuri/del")}'
            class='layui-btn layui-btn-small layui-btn-danger'><i class='fa fa-remove'></i> 删除{$title}
    </button>
    {/if}
</div>
{/block}

{block name="content"}

<!-- 表单搜索 开始 -->
<form class="layui-form layui-form-pane form-search" action="__SELF__" onsubmit="return false" method="get">

    <div class="layui-form-item layui-inline">
        <!--<label class="layui-form-label" style="width:auto">名称</label>-->
        <div class="layui-input-inline">
            <input name="title" value="{$Think.get.title|default=''}" placeholder="名称" class="layui-input">
        </div>
        <div class="layui-input-inline">
            <input name="path" value="{$Think.get.path|default=''}" placeholder="路径" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item layui-inline">
        <div class="layui-input-inline">
            <select name='status' class='layui-select'>
                <option  value="">根据状态搜索</option>
                <option  value='0'>正常</option>
                <option  value='1'>禁用</option>
            </select>
        </div>
    </div>

    <div class="layui-form-item layui-inline">
        <div class="layui-input-inline">
            <button type="submit" class="btn btn-sm btn-white"><i class="fa fa-search"></i> 搜索</button>
        </div>
    </div>

</form>
<!-- 表单搜索 结束 -->

<form onsubmit="return false;" data-auto="" method="POST">
    <input type="hidden" value="resort" name="action"/>
    <div class="layui-form">
        <table class="table table-hover">
            <thead>
            <tr>
                <th>
                    <input data-none-auto="" data-check-target='.list-check-box' lay-skin="primary" lay-filter="allChoose" type="checkbox">
                </th>
                <th class='text-center'>ID</th>
                <th class='text-center'>标题</th>
                <th class='text-center'>路径</th>
                <th class='text-center'>创建者</th>
                <th class='text-center'>创建时间</th>
                <th class='text-center'>状态</th>
                <th class='text-center'>操作</th>
            </tr>
            </thead>
            <tbody>
            {foreach $list as $key=>$vo}
            <tr>
                <td>
                    <input class="list-check-box" value='{$vo.id}' lay-skin="primary" type="checkbox">
                </td>
                <td class='text-center'>{$vo.id}</td>
                <td class='text-center'>{$vo.title}</td>
                <td class='text-center'>{$vo.path}</td>
                <td class='text-center'>{$vo.create_by|get_model_value='SystemUser','username'|default='系统'}</td>
                <td class='text-center'>{$vo.create_at|date='Y-m-d H:i:s',###}</td>
                <td class='text-center'>
                    {if $vo.status eq 1}
                    <span>禁用</span>
                    {else /}
                    <span style="color:#090">正常</span>
                    {/if}
                </td>
                <td class='text-center nowrap'>
                    <div class="layui-btn-group">

                        {if $vo.status eq 0 and auth("$classuri/forbid")}
                        <button type="button" data-update="{$vo.id}" data-field='status' data-value='1' data-action='{:url("$classuri/forbid")}' class="layui-btn layui-btn-primary layui-btn-small">禁用</button>
                        {elseif $vo.status eq 1 and auth("$classuri/resume")}
                        <button type="button" data-update="{$vo.id}" data-field='status' data-value='0' data-action='{:url("$classuri/resume")}' class="layui-btn layui-btn-primary layui-btn-small">开启</button>
                        {/if}

                        {if auth("$classuri/add")}
                        <button type="button" data-modal='{:url("$classuri/add")}?id={$vo.id}' class="layui-btn layui-btn-primary layui-btn-small"><i class="layui-icon"></i></button>
                        {/if}

                        {if auth("$classuri/del")}
                        <button type="button" data-update="{$vo.id}" data-field='delete' data-action='{:url("$classuri/del")}' class="layui-btn layui-btn-primary layui-btn-small"><i class="layui-icon"></i></button>
                    </div>
                </td>
            </tr>
            {/foreach}
            </tbody>
        </table>
    </div>
    {if isset($page)}<p>{$page}</p>{/if}
</form>

<script>window.form.render();</script>
<script>
    layui.use('form', function(){
        var $ = layui.jquery, form = layui.form;

        //全选
        form.on('checkbox(allChoose)', function(data){
            var child = $(data.elem).parents('table').find('tbody input[type="checkbox"]');
            child.each(function(index, item){
                item.checked = data.elem.checked;
            });
            form.render('checkbox');
        });

    });
</script>

{/block}